package org.tang.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class StreamTest {
    public static void main(String[] args) {
        List<User> userList=new ArrayList<>();
        userList.add(new User(1,"ttt","222"));
        userList.add(new User(2,"xxx","333"));
        userList.add(new User(3,"yyy","444"));
        Map<String, String> map = userList.stream().collect(Collectors.toMap(User::getUsername, User::getPassword));
        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry.getKey()+":"+entry.getValue());
        }
    }
}
